package com.mb.app.appused.tools;

import java.util.Map;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

/**
 * 切换Activity
 * 
 * @author wo2app
 * @email wo2app@qq.com
 * @time 2015年6月29日
 * @version Vx.x.x
 * @function
 */
public class ToActivity {

	Context context;

	public ToActivity(Context context) {
		this.context = context;
	}

	public ToActivity(Context context, Class<?> activity) {
		this.context = context;
		toActivity(activity);
	}

	public void toActivity(Class<?> activity) {
		Intent intent = new Intent(this.context, activity);
		this.context.startActivity(intent);
	}

	public static void toActivity(Context context, Class<?> activity) {
		Intent intent = new Intent(context, activity);
		context.startActivity(intent);
	}

	public static void toActivity(Context context, Class<?> activity,
			String[] key, String[] value) {
		Intent intent = new Intent(context, activity);
		int count = key.length < value.length ? key.length : value.length;
		Bundle bundle=new Bundle();
		
		for (int i = 0; i < count; i++) {
			intent.putExtra(key[i], value[i]);
			bundle.putString(key[i], value[i]);
		}
		intent.putExtras(bundle);
		context.startActivity(intent);
	}

	public static void toActivity(Context context, Class<?> activity,
			Map<String, String> map) {
		Intent intent = new Intent(context, activity);
		
		Bundle bundle=new Bundle();
		
		for (Map.Entry<String, String> enter : map.entrySet()) {
			intent.putExtra(enter.getKey(), enter.getValue());
			bundle.putString(enter.getKey(), enter.getValue());
		}
		intent.putExtras(bundle);
		context.startActivity(intent);
	}

	public static void toWebActivity(Context context, Class<?> activity,
			String title, String url) {
		Intent intent = new Intent(context, activity);
		intent.putExtra("url", url);
		intent.putExtra("title", title);
		context.startActivity(intent);
		//overridePendingTransition(R.anim.translate_left, R.anim.translate_right);  
		
	}
}
